﻿using System;
using System.Configuration;
using System.Data;

using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.IO;
using System.Xml;

namespace WebApplication1
{
    public partial class ControlPannel : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["usr"] != null)
                Response.Write("hi");
            //    Response.Redirect("home.aspx");
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Session["usr"] = null;
            Response.Redirect("home.aspx");
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            string ConnStr = "";
            ConnStr = ConfigurationManager.ConnectionStrings["connmTunez"].ToString();
            SqlConnection Conn = new SqlConnection(ConnStr);
            Conn.Open();

            SqlCommand chk = new SqlCommand();
            chk.Connection = Conn;
          //  chk.CommandText = "checkVid";
           
                if (txtHQ.Text !="" && txtMTag.Text !="" && txtNormal.Text !="" && txtSubTag.Text !="" && txtTitle.Text !="" && txtVID.Text !="")
                {
                    chk.Parameters.Clear();                   
                    chk.CommandType = System.Data.CommandType.StoredProcedure;                    
                        chk.Parameters.Clear();
                        chk.CommandText = "saveRecord";
                        chk.Parameters.AddWithValue("@videoID", txtVID.Text );
                        chk.Parameters.AddWithValue("@title", txtTitle.Text  );
                        chk.Parameters.AddWithValue("@date", Convert.ToDateTime(DateTime.UtcNow));
                        chk.Parameters.AddWithValue("@mainTag", txtMTag.SelectedItem.Text);
                        chk.Parameters.AddWithValue("@subTag", txtSubTag.Text  );
                        chk.Parameters.AddWithValue("@rtspHQ", txtHQ.Text );
                        chk.Parameters.AddWithValue("@rtspNormal", txtNormal.Text );
                        chk.CommandType = System.Data.CommandType.StoredProcedure;
                        chk.ExecuteNonQuery();
                        Response.Write("Record Added");
            }

        }

        protected void btnUpdateAlbum_Click(object sender, EventArgs e)
        {
            string ConnStr = "";
            ConnStr = ConfigurationManager.ConnectionStrings["connmTunez"].ToString();
            SqlConnection Conn = new SqlConnection(ConnStr);
            Conn.Open();

            SqlCommand chk = new SqlCommand();
            chk.Connection = Conn;
            if (txtAlbum.Text != "" && txtAlbumCover.Text != "")
            {
                chk.Parameters.Clear();
                chk.Parameters.AddWithValue("@album", txtAlbum.Text.Trim());
                chk.Parameters.AddWithValue("@date", Convert.ToDateTime(DateTime.UtcNow));
                chk.Parameters.AddWithValue("@albumCover", txtAlbumCover.Text.Trim());
                chk.CommandText = "saveAlbum";
                chk.CommandType = System.Data.CommandType.StoredProcedure;
                chk.ExecuteNonQuery();
                Response.Write("Record Added");
            }
        }

        protected void btnUpdateSng_Click(object sender, EventArgs e)
        {
            string ConnStr = "";
            ConnStr = ConfigurationManager.ConnectionStrings["connmTunez"].ToString();
            SqlConnection Conn = new SqlConnection(ConnStr);
            Conn.Open();

            SqlCommand chk = new SqlCommand();
            chk.Connection = Conn;
            if (txtSngAlbum.Text != "" && txtSngSong.Text != "" && txtSngArtist.Text != "" && txtSngTitle.Text != "")
            {
                chk.Parameters.Clear();
                chk.Parameters.AddWithValue("@album", txtSngAlbum.Text.Trim());
                chk.Parameters.AddWithValue("@song", txtSngSong.Text.Trim());
                chk.Parameters.AddWithValue("@sngArtist", txtSngArtist.Text.Trim());
                chk.Parameters.AddWithValue("@sngTitle", txtSngTitle.Text.Trim());
                chk.CommandText = "saveSng";
                chk.CommandType = System.Data.CommandType.StoredProcedure;
                chk.ExecuteNonQuery();
                Response.Write("Record Added");
            }
        }
    }
}